CMake: Rewrite FindMKL.cmake#7595
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request rewrites cmake/modules/FindMKL.cmake to expose ABACUS-oriented oneMKL link closures (BLAS/LAPACK/FFTW, plus BLACS/ScaLAPACK+MPI for MPI builds) instead of exposing individual MKL libraries, and adjusts the build to support MPI-flavor auto-detection for the BLACS interface.
Changes:
- Replace
FindMKL.cmakewith a closure-based design that providesMKL::MKLandMKL::MKL_SCALAPACK, plus cache axes for link mode/threading/MPI ABI. - Enable MPI library-version probing (when not cross-compiling) so MKL can auto-select the correct BLACS interface.
- Switch the core linalg link closure to consume
${MKL_LIBRARIES}and key offMKL_FOUND.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
cmake/modules/FindMKL.cmake |
Reworked MKL discovery to build ABACUS-specific imported-target closures with explicit threading/link-mode/MPI-ABI handling. |
CMakeLists.txt |
Enables MPI_DETERMINE_LIBRARY_VERSION pre-probing for improved Open MPI detection used by the MKL finder. |
source/CMakeLists.txt |
Updates the linalg closure to link via ${MKL_LIBRARIES} and key off MKL_FOUND. |
ecf17f8 to
c92fe8b
Compare
QuantumMisaka
left a comment
There was a problem hiding this comment.
I expanded the MKL-path review across the documented build/install flows. The existing Docker, toolchain, and conda docs mostly still drive MKL through MKLROOT, so those paths explain why CI stays green. The new MKL_ROOT entry point added by this PR is still not propagated consistently.
4dabab4 to
7a8c468
Compare
This reworks
FindMKL.cmaketo model the oneMKL link closure required by ABACUS rather than exposing individual MKL libraries to callers.ABACUS directly uses LP64 Fortran-style BLAS/LAPACK symbols and, in MPI builds, BLACS/ScaLAPACK routines. The finder now provides:
abacus::mklfor the BLAS/LAPACK and FFTW compatibility interfaces;abacus::mkl_scalapackfor the MPI closure, including ScaLAPACK, the matching BLACS library, base MKL libraries, andMPI::MPI_CXX.The configuration handles the relevant oneMKL choices explicitly:
mkl_gf_lp64for GCC andmkl_intel_lp64otherwise, preserving the established ABACUS interface-library selection;mkl_blacs_openmpi_lp64, while MPICH and Intel MPI usemkl_blacs_intelmpi_lp64, as required by oneMKL.Closes #7568.
Note about visible affects
MKL_MPI=AUTO, MPI library-version probing is enabled beforefind_package(MPI)when the build is not cross-compiled. This allows Open MPI to be detected reliably, but does not work for cross builds. People who process cross builds must select the BLACS interface explicitly throughMKL_MPIwhen using MKL.-- oneMKL BLACS interface: ${_mkl_blacs_name}and ensure${_mkl_blacs_name}here ismkl_blacs_openmpi_lp64; normally this should work fine.mkl_gf_lp64.MKL_INCLUDEare no longer available to pass manually, as this is the responsibility of internal logic.